<extend name="Index/index" />

<block name="link">
    <!-- <link rel="shortcut icon" href="http://steamcommunity.com/favicon.ico" type="image/x-icon"> -->
    <link href="__PUBLIC__/css/home_topic/buttons.css" rel="stylesheet" type="text/css">
    <link href="__PUBLIC__/css/home_topic/globalv2.css" rel="stylesheet" type="text/css">
    <link href="__PUBLIC__/css/home_topic/apphub.css" rel="stylesheet" type="text/css">
    <link href="__PUBLIC__/css/home_topic/apphub_home.css" rel="stylesheet" type="text/css">
    <link href="__PUBLIC__/css/home_topic/forums.css" rel="stylesheet" type="text/css">
    <!-- 样式文件 -->
    <link rel="stylesheet" href="__ROOT__/umeditor/themes/default/css/umeditor.css">
    <!-- 引用jquery -->
    <script src="__PUBLIC__/js/home_index/jquery.min.js"></script>
    <!-- 配置文件 -->
    <script type="text/javascript" src="__ROOT__/umeditor/umeditor.config.js"></script>
    <!-- 编辑器源码文件 -->
    <script type="text/javascript" src="__ROOT__/umeditor/umeditor.js"></script>
    <!-- 语言包文件 -->
    <script type="text/javascript" src="__ROOT__/umeditor/lang/zh-cn/zh-cn.js"></script>
    <!-- 实例化编辑器代码 -->
    <script type="text/javascript">
        $(function(){
            window.um = UM.getEditor('container', {
                /* 传入配置参数,可配参数列表看umeditor.config.js */
                toolbar: ['source | undo redo | bold italic underline |  forecolor | selectall cleardoc | emotion image map'
            ]
            });
        });
    </script>
</block>
<block name="main">
    <div class="apphub_HomeHeaderContent">
        <div class="apphub_sectionTabs responsive_hidden">
            <a href="<{:U('Topic/index')}>"  class="apphub_sectionTab active "><span>全部</span></a>
            <a href="<{:U('Topic/index')}>"  class="apphub_sectionTab "><span>讨论</span></a>
            <div style="clear: left"></div>
        </div>
    </div>

    <div id="AppHubContent" class="apphub_Discussion_Content" style="min-height:403px">
        <div class="leftcol">
            <div class="forum_area" id="forum_General_3703047_area">
                
<div id='theme'>
                <div class="forum_paging forum_paging_header">
                    <div class="forum_paging_summary ellipsis">
                        正在显示第 <span id="forum_General_3703047_pagestart"><{$first}></span>-<span id="forum_General_3703047_pageend"><{$last}></span> 个活跃主题，共 <span id="forum_General_3703047_pagetotal"><{$count}></span> 个</div>
                    <div style="clear: both;"></div>
                </div>
                <div id="forum_General_3703047_topiccontainer" class="forum_topics_container">
                    <div id="topic_title" class="forum_topics">
                        <volist name="data" id="vo">
                        <div class="forum_topic  unread locked sticky" >
                            <a class="forum_topic_overlay" href="<{:U('theme',['t'=>$vo['t_id']])}>">
                            </a>
                            <div class="forum_topic_details">
                                <div class="forum_topic_reply_count">
                                    <img src="__PUBLIC__/images/home_topic/comment_quoteicon.png">
                                    <{$vo.reply_num}>
                                </div>
                                <div class="forum_topic_lastpost">
                                    <{$vo.lasttime|date="Y-m-d H:i:s",###}></div>
                            </div>
                            <div class="forum_topic_name">
                                <span class="forum_topic_label sticky_label"><font><!-- 置顶: --></font></span>
                                <{$vo.title}>
                            </div>
                            <div class="forum_topic_op">
                                <if condition="$vo.nickname"><{$vo.nickname}>
                                <else /><{$vo.email}>
                                </if>
                            </div>
                        </div>
                        </volist>
                    </div>
                <div id="page">
                <{$page}>
                </div>
                <script>
                    $('#page div').attr('class','').css({'margin':'15px 0'}).children('li').css({'float':'left','font-size':'14px','padding':'3px 7px'});
                </script>
                </div>
                <div class="forum_paging forum_paging_footer">
                </div>
                <div id="umeditor" style="display:none">
                <span class="glyphicon glyphicon-pencil" style=" font-size:14px;font-family: Microsoft Yahei,ST Hei">发表新帖</span>
                <input id="title" type="text" style="height:25px;width:630px;background:#fff;padding:5px;font:17px 微软雅黑;color:#000" placeholder="请输入标题">
                <div style="margin:10px 0px">
                    <script id="container" name="content" type="text/plain" style="width:640px;height:200px;"></script>
                    <button class="btn" style="margin-top:5px">发表</button>
                </div>
                </div>
</div>
            </div>
        </div>
        <div class="rightcol responsive_local_menu">
            <form class="" method="GET" name="DiscussionSearchForm" action="">
                <div class="discussionSearchTextContainer">
                    <input class="discussionSearchText" type="text" name="q" value="" placeholder="搜索讨论">
                    <img class="discussionSearchTextSubmitImg" src="__PUBLIC__/images/home_topic/searchbox_workshop_submit.gif" width="23" height="18" border="0">
                </div>
            </form>
            <br>
            <div class="rightbox">
                <div class="content">
                    <a class="btn_darkblue_white_innerfade btn_medium " style="background:#333"><span>发起新讨论</span></a>
                </div>
            </div>
        </div>
        <div style="clear: both;"></div>
    </div>

    <div style="height:30px"></div>

    <script>
        $.ajax({
            url:"<{:U('Topic/check_session')}>",
                success:function(data){
                    if (data == 1) {
                        $('#umeditor').css('display','block')
                    }
                }
        })
        $('a:contains("发起新讨论")').click(function(){
            $.ajax({
                url:"<{:U('Topic/check_session')}>",
                success:function(data){
                    if (data) {
                        $('body').scrollTop(100000);
                        $('#title').focus();
                    }else{
                        alert('请先登录');
                        window.location.href = "<{:U('Login/index')}>";
                    }
                }
            })
            
        })

        $('button:contains("发表")').click(function(){
            var title = $('#title').val();
            var content = um.getContent();
            $.ajax({
                type:'post',
                url:"<{:U('Topic/add')}>",
                data:{'title':title,'content':content},
                success:function(data){
                    if (data==1) {alert('发表失败');}
                    window.location.reload();
                }
            })
        })
    </script>
</block>
